package com.example.mbl.controller;

import com.example.mbl.dto.TeacherDto;
import com.example.mbl.entity.PostDoctor;
import com.example.mbl.entity.Teacher;
import com.example.mbl.interceptor.AppToken;
import com.example.mbl.result.PageResult;
import com.example.mbl.result.WebRestResult;
import com.example.mbl.result.business.PostDoctorPageResult;
import com.example.mbl.result.business.TeacherPageResult;
import com.example.mbl.result.business.TeacherResult;
import com.example.mbl.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("Teacher")
public class TeacherController {
    @Autowired
    private TeacherService teacherService;

    @AppToken
    @PostMapping("addTeacher")
    public WebRestResult addTeacher(@RequestBody Teacher teacher){
        WebRestResult result = teacherService.addTeacher(teacher);
        return result;
    }

    @AppToken
    @PostMapping("deleteTeacher")
    public WebRestResult deleteTeacher(@RequestBody Teacher teacher){
        WebRestResult result = teacherService.deleteTeacher(teacher);
        return result;
    }

    @AppToken
    @PostMapping("updateTeacher")
    public WebRestResult updateTeacher(@RequestBody Teacher teacher){
        WebRestResult result = teacherService.updateTeacher(teacher);
        return result;
    }

    @AppToken
    @PostMapping("setTeacherVisible")
    public WebRestResult setTeacherVisible(@RequestBody Teacher teacher){
        WebRestResult result = teacherService.setTeacherVisible(teacher);
        return result;
    }

    @GetMapping("getTeacherList")
    public PageResult<TeacherPageResult> getTeacherList(int page,int pagesize){
        PageResult<TeacherPageResult> result = teacherService.getTeacherList(page,pagesize);
        return result;
    }

    @GetMapping("getTeacherItem")
    public TeacherResult getTeacherItem(String teacherid){
        TeacherResult result = teacherService.getTeacherItem(teacherid);
        return result;
    }

    @AppToken
    @PostMapping("addTeacherEducation")
    public WebRestResult addTeacherEducation(@RequestBody TeacherDto teacherDto){
        WebRestResult result = teacherService.addTeacherEducation(teacherDto);
        return result;
    }

    @AppToken
    @PostMapping("addTeacherAward")
    public WebRestResult addTeacherAward(@RequestBody TeacherDto teacherDto){
        WebRestResult result = teacherService.addTeacherAward(teacherDto);
        return result;
    }

    @AppToken
    @PostMapping("addTeacherArticle")
    public WebRestResult addTeacherArticle(@RequestBody TeacherDto teacherDto){
        WebRestResult result = teacherService.addTeacherArticle(teacherDto);
        return result;
    }

    @AppToken
    @PostMapping("deleteTeacherEducation")
    public WebRestResult deleteTeacherEducation(@RequestBody TeacherDto teacherDto){
        WebRestResult result = teacherService.deleteTeacherEducation(teacherDto);
        return result;
    }

    @AppToken
    @PostMapping("deleteTeacherAward")
    public WebRestResult deleteTeacherExperience(@RequestBody TeacherDto teacherDto){
        WebRestResult result = teacherService.deleteTeacherAward(teacherDto);
        return result;
    }

    @AppToken
    @PostMapping("deleteTeacherArticle")
    public WebRestResult deleteTeacherArticle(@RequestBody TeacherDto teacherDto){
        WebRestResult result = teacherService.deleteTeacherArticle(teacherDto);
        return result;
    }

    @AppToken
    @PostMapping("addPostDoctor")
    public WebRestResult addPostDoctor(@RequestBody PostDoctor postDoctor){
        WebRestResult result = teacherService.addPostDoctor(postDoctor);
        return result;
    }

    @AppToken
    @PostMapping("deletePostDoctor")
    public WebRestResult deletePostDoctor(@RequestBody PostDoctor postDoctor){
        WebRestResult result = teacherService.deletePostDoctor(postDoctor);
        return result;
    }

    @AppToken
    @PostMapping("updatePostDoctor")
    public WebRestResult updatePostDoctor(@RequestBody PostDoctor postDoctor){
        WebRestResult result = teacherService.updatePostDoctor(postDoctor);
        return result;
    }

    @GetMapping("getPostDoctorList")
    public PageResult<PostDoctorPageResult> getPostDoctorList(int page,int pagesize){
        PageResult<PostDoctorPageResult> result = teacherService.getPostDoctorList(page,pagesize);
        return result;
    }
}
